package com.time.sky.mapper;

import com.time.sky.entity.Binfo;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface BinfoMapper {
    @Select("select * from BINFO")
    List<Binfo> selectList();
    @Insert("insert into BINFO(bname,carea,usearea,cellnumber,floornum,holdnum,buildpose,buildtype,structuretype,strunature,liftinfo,buildinfo) " +
            "values(#{bname},#{carea},#{usearea},#{cellnumber},#{floornum},#{holdnum},#{buildpose},#{buildtype},#{structuretype},#{strunature},#{liftinfo},#{buildinfo})")
    void add(Binfo binfo);
    @Delete("delete from BINFO where bid=#{bid}")
    void delete(int bid);
    @Select("SELECT * FROM BINFO  where bid=#{bid}")
    Binfo getById(int bid);
    @Update("update BINFO set bname=#{bname},carea=#{carea},usearea=#{usearea},cellnumber=#{cellnumber},floornum=#{floornum},holdnum=#{holdnum}" +
            " ,buildpose=#{buildpose},buildtype=#{buildtype},structuretype=#{structuretype},strunature=#{strunature},liftinfo=#{liftinfo},buildinfo=#{buildinfo} where bid=#{bid}")
    void update(Binfo binfo);
    @Select("select count(*) from BINFO")
    int getRowCount();
    @Select("<script>select * from Binfo <where><if test='bname != null'>and bname like CONCAT('%',#{bname},'%')</if>" +
            "<if test='buildtype != null'>and buildtype like CONCAT('%',#{buildtype},'%')</if>" +
            "<if test='liftinfo != null'>and liftinfo like CONCAT('%',#{liftinfo},'%')</if></where></script>")
    List<Binfo> selectById(Binfo binfo);

    @Delete("<script>" +
            "delete from Binfo where bid in " +
            "<foreach collection='list' item='hid' open='(' separator=',' close=')'>#{hid}</foreach> " +
            "</script>")
    void deleteBatch(List<Integer> idList);
}
